<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1 {
            /* width: 200px;
            height: 200px; */
            background-color: #bfa;
            border: 10px solid red;
        }

        .box2 {
            width: 100px;
            height: 100px;
            background-color: orange;
            /* margin-top: 100px; */
            float: left;
        }

        /* ::before 在box1和box2之间添加一些内容，这样两者的外边距就不会重叠在一起，自然就不会有外边距重叠问题 */
        /* ::after 解决高度塌陷问题 */
        .box1::before,
        .box1::after {
            content: '';
            display: table;
            clear: both;
        }
    </style>
</head>

<body>
    <div class="box1 clearfix">
        <div class="box2"></div>
    </div>
</body>

</html>